package com.balabala.gym_goods.controller.admin;

import com.balabala.goods.pojo.dto.BookCourseQueryDto;
import com.balabala.goods.pojo.vo.BookCourseDto;
import com.balabala.gym_enum.ResultEnum;
import com.balabala.gym_goods.pojo.dto.*;
import com.balabala.gym_goods.pojo.vo.CourseVo;
import com.balabala.gym_goods.service.BookCourseService;
import com.balabala.gym_goods.service.CourseService;
import com.balabala.result.Result;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author fsj
 * @date 2023/5/5 19:15
 */
@RestController
@Slf4j
@CrossOrigin
@Api(tags = "预约课程信息后台接口")
@RequestMapping("/admin/BookCourse")
public class BookCourseController {
    @Autowired
    private BookCourseService bookCourseService;


    @PostMapping("/findListByQueryDto")
    @ApiOperation("查询预约课程信息")
    public Result findListByQueryDto(@RequestBody BookCourseQueryDto bookCourseQueryDto)
    {
        //1.构建分页条件
        PageHelper.startPage(bookCourseQueryDto.getPage(), bookCourseQueryDto.getLimit());
        //查询
        List<BookCourseDto> listByQueryDto = bookCourseService.findListByQueryDto(bookCourseQueryDto);
        //分页插件
        PageInfo<BookCourseDto> pageInfo = new PageInfo<>(listByQueryDto);

        return Result.ok(pageInfo.getList(),pageInfo.getTotal());
    }

    //根据预约课程id查询预约课程信息
    @GetMapping("/findByScheduleId")
    @ApiOperation("预约课程详情信息")
    public Result findByScheduleId(@RequestParam Long scheduleId){

        BookCourseDto byScheduleId = bookCourseService.findByScheduleId(scheduleId);

        return Result.ok(byScheduleId);
    }



}
